package com.example.common.adapter

import android.widget.ImageView
import androidx.databinding.BindingAdapter
import com.example.image.ImageLoadUtil
import com.example.image.ImageOptions

object CommonBindingAdapter {

    @JvmStatic
    @BindingAdapter("imageUrl")
    fun loadUrlImage(imageView: ImageView,url:String){
        if(url.isNotEmpty()){
            ImageLoadUtil.with(imageView.context).loadUrl(url).into(imageView)
        }

    }

    @JvmStatic
    @BindingAdapter("imageCircleUrl")
    fun loadUrlCircleImage(imageView: ImageView,url:String){
        if(url.isNotEmpty()){
            var options = ImageOptions.Builder.isCircle(true).build()

            ImageLoadUtil.with(imageView.context).loadUrl(url).setOptions(options).into(imageView)
        }
    }

//    @JvmStatic
//    @BindingAdapter("bgColor")
//    fun loadUrlColor(imageView: ImageView,url:String){
//        if(url.isNotEmpty()){
//            var options = ImageOptions.Builder.isCircle(true).build()
//
//            ImageLoadUtil.with(imageView.context).loadUrl(url).setOptions(options).into(imageView)
//        }
//    }
}